package com.duoshu.grj.sosoliuda.ui.player;

import android.content.pm.ActivityInfo;
import android.content.res.Configuration;

import com.duoshu.grj.sosoliuda.R;
import com.duoshu.grj.sosoliuda.ui.base.SosoBaseActivity;

import butterknife.BindView;

/**
 * 项目名称：Sosoliuda
 * 类描述：
 * 创建人：周作威
 * 创建时间：2017/5/18
 */

public class PlayerActivity extends SosoBaseActivity {
    @BindView(R.id.playerview)
    PlayerView playerview;
    private String player_id;
    private String player_title;
    public static final String PLAYER_ID = "PLAYER_ID";
    public static final String PLAYER_TITLE = "PLAYER_TITLE";

    @Override
    protected void initUI() {
        setContentView(R.layout.activity_player);
        player_id = getIntent().getExtras().getString(PLAYER_ID);
        player_title = getIntent().getExtras().getString(PLAYER_TITLE);
        playerview.setPlayer(player_id, player_title, true);
        onConfigurationChanged(getResources().getConfiguration());
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        playerview.onResume();
    }

    @Override
    protected void onStop() {
        super.onStop();
        playerview.onStop();
    }

    @Override
    protected void onDestroy() {
        playerview.onDestroy();
        super.onDestroy();
    }

    @Override
    public void onBackPressed() {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            super.onBackPressed();
        }else{
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        playerview.onConfigurationChanged(newConfig);
    }
}
